﻿using System;
using Mockery.Core;
using NUnit.Framework;

namespace Mockery.UnitTest
{
    [TestFixture]
    public class InjectedTestTests
    {
        private const int TestValue = 10;
        public virtual int Go() 
        {
            return TestValue; 
        }

        public interface IStub
        {
            void Go();
        }

        public void Throws(string value)
        {
            throw new ArgumentNullException("value");
        }

        [Test]
        public void InjectedTest_Instantiate()
        {
            // this test needs some work
            Assert.That(InjectedTest.Target<InjectedTestTests>(), Is.Not.Null);
        }

        [Test]
        public void InjectedTest_InstantiateWithInitializeTest()
        {

            var checkValue = 0;
 
            InjectedTest.Target<InjectedTestTests>(t => checkValue = t.Go())
                .Arrange( a=> a.AddStub<IStub>())
                .Assert(() => Assert.That(checkValue, Is.EqualTo(TestValue)));
        }

        [Test]
        public void InjectedTest_CatchOnInitializeTest()
        {
            InjectedTest.Target<InjectedTestTests>(t => t.Throws("test"))
                .Arrange( a => a.AddStub<IStub>())
                .AssertException<ArgumentNullException>(a => Assert.That(a.ParamName, Is.EqualTo("value")));
           
        }
    }
}
